package Afternoon;

import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;

public class Test2 {

    public static void main(String[] args) {

        TreeMap<Students, Integer> map = new TreeMap<>(new Comparator<Students>() {
            @Override
            public int compare(Students o1, Students o2) {

                int relt = o1.getScore() - o2.getScore();

                if (relt == 0) {

                    Collator res = Collator.getInstance(Locale.CHINA);
                   relt = res.compare(o1.getName(),o2.getName() );

                }
                return relt;
            }
        });


        map.put(new Students("张三丰", 45, 100), 1);
        map.put(new Students("翠山", 35, 90), 2);
        map.put(new Students("杨晓", 55, 100), 3);
        map.put(new Students("灭绝师太", 88, 0), 4);


        for (Map.Entry<Students, Integer> entry : map.entrySet()) {
            System.out.println(entry);
        }


    }
}